/**
 * 
 */
package com.alkandros.calculator.ui.share;

import android.app.Fragment;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;

import com.alkandros.calculator.R;

/**
 * @author Jiju Induchoodan
 *
 */
public class ShareFragment extends Fragment implements OnClickListener{

	View rootView;
	private ImageView btnFacebook;
	private ImageView btnBlog;
	private ImageView btnPininterest;
	private ImageView btnGooglePlus;
	private ImageView btnYoutube;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) 
	{
		rootView = inflater.inflate(R.layout.fragment_share, container, false);
		initialiseUI();
		return rootView;
	}
	
	private void initialiseUI()
	{
		btnBlog   				= (ImageView)rootView.findViewById(R.id.btn_blog);
		btnFacebook     		= (ImageView)rootView.findViewById(R.id.btn_fb);
		btnPininterest  		= (ImageView)rootView.findViewById(R.id.btn_pininterest);
		btnGooglePlus         	= (ImageView)rootView.findViewById(R.id.btn_gplus);
		btnYoutube         		= (ImageView)rootView.findViewById(R.id.btn_youtube);
		
		btnBlog.setOnClickListener(this);
		btnFacebook.setOnClickListener(this);
		btnPininterest.setOnClickListener(this);
		btnGooglePlus.setOnClickListener(this);
		btnYoutube.setOnClickListener(this);
	}
	@Override
	public void onClick(View v) 
	{
		if(v==btnBlog)
		{
			navigateToBrowser(getString(R.string.blog_url));
		}
		else if(v==btnFacebook)
		{
			navigateToBrowser(getString(R.string.facebook_url));
		}
		else if(v==btnGooglePlus)
		{
			navigateToBrowser(getString(R.string.google_plus));
		}
		else if(v==btnPininterest)
		{
			navigateToBrowser(getString(R.string.pininterest_url));
		}
		else if(v==btnYoutube)
		{
			navigateToBrowser(getString(R.string.youtube_url));
		}
	}
	private void navigateToBrowser(String url)
	{
		Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
		startActivity(browserIntent);
	}

}
